package com.higold.cloud.mvp.presenter

import com.higold.cloud.base.BasePresenter
import com.higold.cloud.mvp.contract.MarketListContract
import com.higold.cloud.mvp.model.MarketListModel
import com.higold.cloud.net.exception.ExceptionHandle

/**
 *    author : lxz
 *    date   : 2019/9/7 11:10
 *    desc   :
 */
class MarketListPresenter : BasePresenter<MarketListContract.View>(), MarketListContract.Presenter {

    private val marketListModel by lazy { MarketListModel() }

    override fun getMarketList() {
        checkViewAttached()
        mRootView?.showLoading()
        val disposable = marketListModel.requestDevelopList()
                .subscribe({  marketList->
                    mRootView?.setMarketList(marketList)
                }, { throwable ->
                    //处理异常
                    mRootView?.showError(ExceptionHandle.handleException(throwable), ExceptionHandle.errorCode)
                })
        addSubscription(disposable)    }

}